package com.arpa.ntocc.common.domain.entity;

import com.arpa.ntocc.common.common.validator.Save;
import com.arpa.ntocc.common.common.validator.Update;
import com.arpa.ntocc.common.common.validator.annotation.PartyGroupCodeExistConstraint;
import com.arpa.ntocc.common.common.validator.annotation.PartyGroupNameExistConstraint;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 组织信息
 * </p>
 *
 * @author wangyujie
 * @since 2020-01-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sys_party_group")
@ApiModel(value="组织信息实体", description="组织信息表sys_party_group")
/*
 * 自定义校验，用来验证组织编码和名称
 */
@PartyGroupNameExistConstraint(groups = {Save.class, Update.class})
public class PartyGroup extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "组织编码")
    @TableField("code")
    @NotBlank(message = "组织编码不能为空", groups = {Save.class, Update.class})
    @Length(max = 20, message = "组织编码长度不能大于20", groups = {Save.class, Update.class})
//    @PartyGroupCodeExistConstraint(groups = {Save.class} )
    private String code;

    @ApiModelProperty(value = "状态：0停用，1启用",hidden = true)
    @TableField("status")
    private Integer status;

    @ApiModelProperty(value = "层级：0顶级，1下级",hidden = true)
    @TableField("level")
    private Integer level;

    @ApiModelProperty(value = "最大用户数")
    @NotNull(message = "最大用户数不能为空", groups = {Save.class, Update.class})
    @Min(value = 1,message = "最大用户数必须大于等于1的正整数", groups = {Save.class, Update.class})
    @TableField("user_quantity")
    private Integer userQuantity;

    @ApiModelProperty(value = "组织名称")
    @NotBlank(message = "组织名称不能为空", groups = {Save.class})
    @Length(max = 256, message = "组织名称长度不能大于256个字符", groups = {Save.class, Update.class})
    @TableField("group_name")
    private String groupName;


}
